﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using MySql.Data;//para el datatable
using MySql.Data.MySqlClient;
using Mapeo;
using NHibernate;

namespace DAL
{
    public class PreActa_DAL
    {
        public DataTable PreActa_ListadoProfesores()
        {
            String cadena = "";
            Conexion conex = new Conexion();
            MySqlCommand cmd = new MySqlCommand();
            MySqlDataAdapter da = new MySqlDataAdapter();
            DataTable data = new DataTable();
            MySqlConnection conexion = new MySqlConnection();
            cadena = conex.ConexionCampusVirtual();

            conexion.ConnectionString = cadena;

            try
            {
                conexion.Open();
                cmd.CommandText = "sp_DATA_PREACTA_ListaProfesores";                
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection = conexion;

                da = new MySqlDataAdapter(cmd);
                da.Fill(data);

                return data;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conexion.Close();
                cmd.Dispose();
            }
        }

        public DataTable PreActa_ListadoProfesores_xNombre(string profesor, string codigo)
        {
            String cadena = "";
            Conexion conex = new Conexion();
            MySqlCommand cmd = new MySqlCommand();
            MySqlDataAdapter da = new MySqlDataAdapter();
            DataTable data = new DataTable();
            MySqlConnection conexion = new MySqlConnection();
            cadena = conex.ConexionCampusVirtual();

            conexion.ConnectionString = cadena;

            try
            {
                conexion.Open();
                cmd.CommandText = "sp_DATA_PREACTA_ListaProfesores_xNombre";
                cmd.Parameters.AddWithValue("@in_nombre", profesor);
                cmd.Parameters.AddWithValue("@in_codigo", codigo);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection = conexion;

                da = new MySqlDataAdapter(cmd);
                da.Fill(data);

                return data;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conexion.Close();
                cmd.Dispose();
            }
        }

        public DataTable PreActa_ListadoAsignaturas_xNombre_XSemestre(string codigoprofesor,string semestre)
        {
            String cadena = "";
            Conexion conex = new Conexion();
            MySqlCommand cmd = new MySqlCommand();
            MySqlDataAdapter da = new MySqlDataAdapter();
            DataTable data = new DataTable();
            MySqlConnection conexion = new MySqlConnection();
            cadena = conex.ConexionCampusVirtual();

            conexion.ConnectionString = cadena;

            try
            {
                conexion.Open();
                cmd.CommandText = "sp_DATA_PREACTA_ListaAsignatura_xNombre_XSemestre";
                cmd.Parameters.AddWithValue("@in_codigo", codigoprofesor);
                cmd.Parameters.AddWithValue("@in_semestre", semestre);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection = conexion;

                da = new MySqlDataAdapter(cmd);
                da.Fill(data);

                return data;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conexion.Close();
                cmd.Dispose();
            }
        }
    }
}
